package com.smartsoft.demo.activity;

import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.widget.Toast;
import android.widget.VideoView;
import com.smartsoft.demo.R;
import com.smartsoft.demo.domain.Contact;
import com.smartsoft.demo.fragment.ContactEditFragment;
import com.smartsoft.demo.fragment.ContactPreviewFragment;

/**
 * Main activity with video view in background.
 */
public class VideoActivity extends Activity {

    //uses for showing main video stream
    private VideoView videoView;

    //Contact edit fragment
    private ContactEditFragment editFragment = new ContactEditFragment();

    /**
     * Starts when Activity is created. Configure and start video view.
     * Add Contact edit fragment to fragment place.
     * @param savedInstanceState saved activity data
     */
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.video);

        //video stream url
        final String videoUrl =
                getResources().getString(R.string.videoUrl);
        //prepare video player an start
        videoView = (VideoView) findViewById(R.id.video);
        videoView.setVideoURI(Uri.parse(videoUrl));
        videoView.start();

        //set contact edit fragment in fragment place`
        FragmentTransaction ft = getFragmentManager().beginTransaction();
        ft.replace(R.id.fragmentPlace, editFragment);
        ft.commit();
    }

}